Skip to content

[ExecuTorch][WebGPU] Add select/boolean ops (where, scalar compares, logical_not) to the WebGPU backend#20925

Open
JCNTH wants to merge 4 commits into
gh/JCNTH/64/basefrom
gh/JCNTH/64/head
Open

[ExecuTorch][WebGPU] Add select/boolean ops (where, scalar compares, logical_not) to the WebGPU backend#20925
JCNTH wants to merge 4 commits into
gh/JCNTH/64/basefrom
gh/JCNTH/64/head

Conversation

@JCNTH

@JCNTH JCNTH commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Add aten.where.self, scalar comparisons (aten.{eq,ne,le,ge,lt,gt}.Scalar), and aten.logical_not.default handlers for the training tail. The scalar compares and logical_not are generated from ONE templated byte-packed-bool shader (runtime/ops/boolean_op/) rather than per-op hand-written kernels — mirroring the binary_op codegen and Vulkan's grouping of comparison ops as ${OPERATOR} variants (backends/vulkan/runtime/graph/ops/glsl/binary_op_buffer.yaml).

Key changes:

  • runtime/ops/boolean_op/ — one boolean_op.wgsl template + boolean_op.yaml (variants compare_{eq,ne,le,ge,lt,gt} + logical_not) expand to the per-variant *_wgsl.h; BooleanOp.cpp holds one shared dispatch_bool_op helper (pack 4 bools per u32 word, one thread per word) plus the seven WEBGPU_REGISTER_OPs.
  • runtime/ops/where/ — ternary select, kept as its own kernel/handler (non-bool-family, as in Vulkan).
  • op_registry.py — register the net-new aten.{ne,lt,le,ge,gt}.Scalar + aten.logical_not.default OpFeatures (eq.Scalar already on master).
  • CMakeLists.txt WEBGPU_SRCS — wire boolean_op/BooleanOp.cpp.

aten.where.self already had Vulkan OpFeatures; the scalar-compare + logical_not registrations are additive to the shared Vulkan registry.

Co-authored-with: Claude Code.
@exported-using-ghexport

Differential Revision: D111755122

Differential Revision: D111755122

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20925

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 14, 2026
This was referenced Jul 14, 2026
[ghstack-poisoned]
[ghstack-poisoned]

@SS-JIA SS-JIA left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

[ghstack-poisoned]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants